<template>
  <div 
  @click="jumpDetails"
  class="big-content">
    <div class="content-box">
      <div class="left-img">
        <v-touch v-on:doubletap="del">
          <img :src="imgUrl" alt="" />
        </v-touch>
      </div>
      <div class="right-info">
        <p>{{title}}</p>
        <p>{{author}}</p>
        <span>{{text}}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    imgUrl:{
      type: String,
    },
    title:{
      type: String,
    },
    author:{
      type: String,
    },
    text:{
      type: String,
    },
    index:{
      type: Number,
    },
  },
  name: "Hot",
  data(){
        return {
            infoObj: {imgUrl:this.imgUrl, title:this.title, author:this.author, text:this.text,},
            flag: true,
        }
    },
    methods:{
        jumpDetails(){
            this.$emit("setData",{infoObj:this.infoObj,flag:this.flag})
        },
        del(){
          this.$emit("del", this.index);
          let dataArr = JSON.parse(localStorage.getItem("dataArr"));
          let datalists = JSON.parse(localStorage.getItem("infoObj"));
          dataArr.splice(this.index,1)
          localStorage.clear(datalists);
          localStorage.setItem("dataArr",JSON.stringify(dataArr));
        }
    }
};
</script>

<style lang="scss" scoped>
.big-content {
    display: flex;
    margin-bottom: 20px;
    justify-content: center;
    padding: 14px 0 0 0;
  .content-box {
    width: 340px;
    display: flex;
    .left-img {
      flex-basis: 30%;
      flex-grow: 0;
      flex-shrink: 0;
      padding-right: 12px;
      height: 110px;
      img {
        width: 100%;
        height: 110px;
        border-radius: 6px;
      }
    }
    .right-info {
      font-size: 0;
      p:first-child{
        font-size: 16px;
        font-weight: bold;
        padding: 8px 0 8px 0;
        letter-spacing: 1px;
      }
      p:nth-child(2){
        font-size: 14px;
        color: #666;
        padding-bottom: 8px;
      }
      span {
        font-size: 14px;
        color: #888;
      }
    }
  }
}
</style>